When Generic Functions Use Dynamic Values
نویسندگان
چکیده
Dynamic types allow strongly typed programs to link in external code at run-time in a type safe way. Generic programming allows programmers to write code schemes that can be specialized at compiletime to arguments of arbitrary type. Both techniques have been investigated and incorporated in the pure functional programming language Clean. Because generic functions work on all types and values, they are the perfect tool when manipulating dynamic values. But generics rely on compile-time specialization, whereas dynamics rely on run-time type checking and linking. This seems to be a fundamental contradiction. In this paper we show that the contradiction does not exist. From any generic function we derive a function that works on dynamics, and that can be parameterized with a dynamic type representation. Programs that use this technique combine the best of both worlds: they have concise universal code that can be applied to any dynamic value regardless of its origin. This technique is important for application domains such as type-safe mobile code and plug-in architectures.
منابع مشابه
Dynamic Construction of Generic Functions
. This paper presents a library for the run-time construction and specialisation of generic or polytypic functions. This library utilises the type information that is available in dynamics to implement generic functions on their values. The library closely follows the static generic framework, both in its use and in its implementation. It can dynamically construct generic operations ranging fro...
متن کامل"Scrap Your Boilerplate" Revolutions
Generic programming allows you to write a function once, and use it many times at different types. Traditionally, generic functions are defined by induction on the structure of types. “Scrap your boilerplate” (SYB) is a radically different approach that dispatches on the structure of values. In previous work, we have shown how to reconcile both approaches using the concept of generic views: man...
متن کاملStability of the Modified Euler Method for Nonlinear Dynamic Analysis of TLP
Efficiency of numerical methods is an important problem in dynamic nonlinear analyses. It is possible to use of numerical methods such as beta-Newmark in order to investigate the structural response behavior of the dynamic systems under random sea wave loads but because of necessity to analysis the offshore systems for extensive time to fatigue study it is important to use of simple stable meth...
متن کاملAn Innovative Method to Modeling Realistic Flexible Robots
In this paper a modular, computationally efficient and numerically stable method is presented, which allows to obtain the dynamic model of a robot constituted by flexible links having varying cross-section and subjected to generic ending forces and torques and to the gravity actions. This method is based on the use of admissible deformation functions of wavelet type, obtained by using the Insta...
متن کاملDynamics for ML using Meta-Programming
We present the design and implementation of dynamic type and value introspection for the OCaml language. Unlike previous attempts, we do not modify the core compiler or type-checker, and instead use the camlp4 metaprogramming tool to generate appropriate definitions at compilation time. Our dynamics library significantly eases the task of generating generic persistence and I/O functions in OCam...
متن کامل